﻿using System;
using System.Linq;


    class ExchangePAndQBits
    {
        static void Main(string[] args)
        {
            int num = 65408;
            Console.WriteLine(Convert.ToString(num, 2));
            int p = 1;
            int q = 10;
            int k = 4;
            int mask = 0;
            for (int i = 0; i < k; i++)
            {
                mask += (int)Math.Pow(2, i);
                
            }
            Console.WriteLine(mask);
                int firstPBits = num & (mask << p);
                int secondQBits = num & (mask << q);

                firstPBits = firstPBits << (q - p);
                Console.WriteLine(Convert.ToString(firstPBits, 2));
                secondQBits = secondQBits >> (q - p);
                Console.WriteLine(Convert.ToString(secondQBits, 2));

                num = num & (~(mask << p));

                num = num & (~(mask << q));

                num = num | firstPBits;
                num = num | secondQBits;
                Console.WriteLine(Convert.ToString(num, 2));
            
            
        }
    }

